#!/usr/bin/env python
import os
import os.path

from AutoD3PDMakerUtility import readStrippedLines
from Ganga.Utility.logging import getLogger

class AutoD3PDMakerPlugin:
    """
    the abstract class implementing basic logics of the plugin methods
    """
    def __init__(self):
        self.logger      = getLogger('AutoD3PDMakerPlugin')

        ## set it to True in the plug-in implementation if running post-process in batch mode
        self.ppBatchMode = False

    def verifyTaskObj(self, taskObj):
        """
        implements the verification of the give taskObj.
        To make sure the given taskObj can be properly handled by other methods in this class.
        """
        raise NotImplementedError("verifyTaskObj not implemented.")

    def getUserBlackListSite(self):
        """
        implements the logic of getting a list of user-level blacklisting sites.

        Default implementation will be looking into a file given by env. variable: AUTOD3PDMAKER_BLSITES
        """

        blsites = []

        if os.environ.has_key('AUTOD3PDMAKER_BLSITES') and os.path.exists( os.environ['AUTOD3PDMAKER_BLSITES'] ):
            blsites = readStrippedLines( os.environ['AUTOD3PDMAKER_BLSITES'] )

        return blsites

    def makeGangaTask(self, taskObj):
        """
        implements the convertion from taskObj to GangaTask.
        """
        raise NotImplementedError("makeGangaTask not implemented.")

    def postprocessTask(self, taskObj):
        """
        implements the logic of post-processing taskObj.
        """
        raise NotImplementedError("postprocessTask not implemented.")

    def makeTaskReport(self, taskObjList):
        """
        implements the logic to convernt the given taskObjList into a human-readable report.
        """
        raise NotImplementedError("makeTaskReport not implemented.")